package com.cskaoyan.utils;


import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * @author WeitenHong
 * @date 2020/10/7 15:14
 */

public class IdUtils {
    public static Integer getId(){
        Subject subject = SecurityUtils.getSubject();
        Object primaryPrincipal;
        try {
            primaryPrincipal = subject.getPrincipals().getPrimaryPrincipal();
        } catch (Exception e) {
            return 0;
        }
        int id = (int) primaryPrincipal;
        return id;
    }
}
